package com.bw.controller;

import com.bw.domain.Sugar;
import com.bw.service.SugarService;
import com.sugar.SugarUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
public class SugarController {
    @Autowired
    SugarService sugarService;
    @RequestMapping("/list1")
    public Map t1(){
        List<Sugar> list = sugarService.getSugarList1();
        return SugarUtil.getMapData(list);
    }

    @RequestMapping("/list2")
    public Map t2(){
        List<Sugar> list = sugarService.getSugarList2();
        return SugarUtil.getPieData(list);
    }

    @RequestMapping("/list3")
    public Map t3(){
        List<Sugar> list = sugarService.getSugarList3();
        return SugarUtil.getPieData(list);
    }

    @RequestMapping("/list4")
    public String t4(){
        List<Sugar> list = sugarService.getSugarList4();
        ArrayList<String> list1 = new ArrayList<>();
        list1.add("品牌");
        list1.add("性别");
        list1.add("总金额");
        return SugarUtil.getTablePlayData(list1,list);
    }
}
